package com.jrh.dal;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.jrh.domain.entity.Showroom;
import com.jrh.domain.entity.User;

/**
 * 用户DAO
 * 
 * @author mmy 2012-7-18 上午2:45:03
 */
public class UserDao extends BaseDao<User> {

    public UserDao(){
        this.namespace = "jrh.single.user";
    }

    /**
     * 通过登入ID获取用户
     * 
     * @param loginId
     * @return
     */
    public User getUserByLoginId(String loginId) {
        return this.getUserByLoginIdAndSite(loginId, User.JRH_SELF_USER_SITE);
    }

    /**
     * 根据登录帐号和网站类型取得用户
     * 
     * @param loginId
     * @param site
     * @return
     */
    public User getUserByLoginIdAndSite(String loginId, String site) {
        Map<String, String> map = new HashMap<String, String>();
        map.put("loginId", loginId);
        map.put("site", site);
        return (User) sqlMapClientTemplate.queryForObject(namespace + "." + "getUserByLoginIdAndSite", map);
    }

    public User getUserByNickname(String nickname) {
        return (User) sqlMapClientTemplate.queryForObject(namespace + "." + "getUserByNickname", nickname);
    }
    
    @SuppressWarnings("unchecked")
    public List<User> finduserid() {
		return  (List<User>) sqlMapClientTemplate.queryForList(namespace + "." + "loaduserid");
	}
}
